<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let name = "root";
        let obj  =  {
            name, // 此时name 既是key 又是value
            age: 20,
            sex: '男',
            print: function(){
                console.log("=======admin=======");
            },
            // 简化版方法声明
            print2(){
                console.log("=======admin2222222=======");
            }
        };
        obj.prototype.print3 = function(){
            
        }

        console.log(obj.name);
        obj.print();
        obj.print2();

        // 拓展运算符
        let z = { a: 3, b: 4 };
        let n = { ...z }; // 根据z变量重新生成一个n变量,新变量和原变量是完全独立的
        let n2 = z; // 它们关联同样的内存地址
        z.a = 10;
        console.log(n);
        console.log(n2);
        // n 值为{ a: 3, b: 4 }
        // 这个方法对于数组也通用
        let foo = { ...['a', 'b', 'c'] };
        // foo：{0: "a", 1: "b", 2: "c"}






    </script>
</body>
</html>